<%--
  Created by IntelliJ IDEA.
  User: cyy
  Date: 2022/11/25
  Time: 14:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.cyy.bean.cart" %>
<%@ page import="java.util.ArrayList" %>
<%@ taglib prefix="rapid" uri="http://www.rapid-framework.org.cn/rapid" %>
<!DOCTYPE html>
<html>
<head>
    <title>我的购物车</title>
</head>
<body>
    <rapid:override name="titleContent">
        <h2 align="center">我的购物车</h2>
        <input type="hidden" id="userName" value=<%=session.getAttribute("name")%>>
        <input type="hidden" id="money" value=<%=request.getAttribute("totalPrice")%>>
        <input type="hidden" id="address" value=<%=session.getAttribute("address")%>>
        <input type="hidden" id="phone" value=<%=session.getAttribute("phone")%>>
    </rapid:override>
    <rapid:override name="mainContent">
        <div class="cart-page">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-8">
                        <div class="cart-page-inner">
                            <div class="table-responsive">
                                <table class="table table-bordered">
                                    <thead class="thead-dark">
                                    <tr>
                                        <th>商品名字</th>
                                        <th>数目</th>
                                        <th>合计</th>
                                        <th>商品状态</th>
                                        <th>移除</th>
                                    </tr>
                                    </thead>
                                    <tbody class="align-middle">
                                        <%
                                            ArrayList<cart> carts=(ArrayList<cart>)request.getAttribute("carts");
                                            if(carts!=null)
                                            {
                                            for (int i=0;i<carts.size();i++) {%>
                                                <tr>
                                                    <td><%=carts.get(i).getProductName()%></td>
                                                    <td><%=carts.get(i).getNum()%></td>
                                                    <td><%=carts.get(i).getNum()*carts.get(i).getPrice()%></td>
                                                    <%if(carts.get(i).getUsability()==1){%>
                                                    <td>在售</td>
                                                    <%}else{%>
                                                    <td>已下架</td>
                                                    <%}%>
                                                    <td><a href="/deleteCart?productName=<%=carts.get(i).getProductName()%>"><i class="fa fa-trash"></i></a></td>
                                                </tr>
                                        <%}}%>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="cart-page-inner">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="cart-summary">
                                        <div class="cart-content">
                                            <p>总数(不包括已下架商品)<span><%=request.getAttribute("totalNum").toString()%>件</span></p>
                                            <p>合计(不包括已下架商品)$<span><%=request.getAttribute("totalPrice").toString()%></span></p>
                                        </div>
                                        <div class="cart-btn">
                                            <button onclick="returnToIndex()">回到首页</button>
                                            <button onclick="buy()">去结算</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </rapid:override>
    <%@ include file="customerProductIndex.jsp"%>
</body>
</html>
